var app = new Vue({
	el: '#app',
	data: {
		host:globalData.constParam.url.baseUrl+'/',
		infos:{
			user:globalData.userInfo
		},//用户的所有信息
		url:{
			getQAUsers: '/api/UserQuestion/GetQAUsers', //获取用户列表
			getSpecialSolutionProductLibImgs:'/api/Banner/GetSpecialSolutionProductLibImgs', //获取banner
			getRecommendProductsByModelID: '/api/Product/GetRecommendProductsByModelID', //获取推荐产品
			getPageProducts:'/api/Product/GetPageProducts', //获取列表产品
		},
		type:0, //产品库，需求分析
		banners:[], //轮播图
		modelList:[],  //分类
		recommend_products:[], //推荐产品列表
		list_item:{}, //详情列表父item
		product_list_detail_show:{value:false}, //详情列表
		users:[], //用户列表
		user:globalData.getUserInfo(),
		CustomerID:'', //客户ID
		children_data: {
			component_data: {
				nextQuestionID: "", //下题ID 
				selectedValue: "", //当前问题的值 
				isStop: false,
				hasTip: false,
				ShowMsg: ''
			},
			control9_10_data: {
				parent_value: [],
				control_out: {
					err: "",
					result: "",
					all_values: ""
				}
			},
			current_question: {},
			currentIndex: 0, //组件中当前题是第几题
			isShow: true, //tab内容、答题内容 切换
			question_step: 0, //答题步骤，基本、问答、推荐
			CustomerID: '', //客户ID
			AnswerItems: [], //答案列表
			answers: {
				name: '',
				mark: '',
				sex: '',
				birthday: '',
				birthplace: '',
				county: '',
				address: '',
				marriage: '',
				hasChild: '',
				occupation: '',
				workyear: '',
				isPep: '',
				industry: '',
				income: '',
				male: '',
				female: ''
			},
			evaluation_result:{}, //评估结果
		},
	},
	computed:{
		childs:function(){
			return (this.answers.male + ',' + this.answers.male)
		}
		
	},
	mounted: function() {
		var that = this
		globalData.getTempToken(function(){			
			//获取轮播图
			that.getSpecialSolutionProductLibImgs()		
			//获取推荐产品
			that.getPageProducts()
		})		
	},
	methods: {	
		showUsers:function(){ //切换tab到用户列表
			var that = this
			if(!globalData.userIsLogin(null,true)){
				return;
			}
			that.type = 1
			this.getQAUsers() //获取用户	
			
		},
		getSpecialSolutionProductLibImgs:function(){
			var that = this
			globalData.ajaxPost(that.url.getSpecialSolutionProductLibImgs,null,function(res){
				//隐藏loading
				$('.loading').hide()
				if(res.suc){
					console.log(res)
					that.banners = res.data
					//初始化轮播图		
					setTimeout(function() {
						that.reset_lunbo()
					}, 100)
				}
			})
			
		},
		getProductCategorysForApp: function() {
			var that = this
			globalData.ajaxPost(that.url.getProductCategorysForApp,{'ModelID':globalData.getStorage('modelID')},function(res){
				if(res.suc){
					console.log(res)
					that.modelList = res.data.ProductCategorys
				}
			})
		},
		getPageProducts: function() {
			var that = this
			var data = {'PageIndex':'1','PageSize':'10000','ModelID':globalData.getStorage('modelID')}
			globalData.ajaxPost(that.url.getPageProducts,data,function(res){
				if(res.suc){
					console.log(res)
					that.recommend_products = res.data
				}
			})
		},
		reset_lunbo: function() {
			var mySwiper = new Swiper('.products_container', {
				loop: true,
				// 如果需要分页器
				pagination: '.products_pagination',
				// 如果需要前进后退按钮
				nextButton: '.products_next',
				prevButton: '.products_prev',
				loop: true,
				autoplay:3000,
				autoplayDisableOnInteraction : false,
				// 如果需要滚动条
				//				scrollbar: '.swiper-scrollbar',
			})
		},
		go_step_2: function(val) { //保存基本问题
			var that = this;
			var data = { 
				"ModelName": "高端生活",
				"UserAnswers": [{ "LoopTag": 1, "AnswerItems": val}]
				}
			console.log(data)
			globalData.ajaxPost(this.url.saveBasicQuestions, data, function(res) {
				if(res.StatusCode == 200) {
					//保存成功，返回客户id
					that.CustomerID = res.data
					console.log(res)
					that.step = 2
				}
			})
		},
		add_customer:function(){
			var that = this
			that.CustomerID = ''
			//初始化
			$.each(that.answers,function(index,item){
				that.answers[index] = ''
			})
			console.log(that.answers)			
			that.step=1
			that.isShow = false
		},
		//获取步骤二数据
		get_my_question:function(){
			var that = this
			var data = {
				"ModelID":"3",
				"QuestionType":2
			}
			globalData.ajaxPost(this.url.getSpecialQuestions, data, function(res) {				
				var data = res.data
				if(res.suc){
					console.log(data)
					that.AnswerOutputs = data[0].AnswerOutputs
					that.QuestionTitle = data[0].QuestionTitle
					console.log(that.AnswerOutputs)
				}
			})
		},
		getQAUsers:function(){
			var that = this
			globalData.ajaxPost(this.url.getQAUsers, null, function(res) {
				console.log(res)
				if(res.suc){
					that.users = res.data
				}
			})
		},
		show_list:function(item){  //获取类别详情页
			console.log(item)
			var that = this 
			that.list_item = item
			
			
			$('.product_list_detail').show()
			this.product_list_detail_show.value = true
		},
		go_introduce:function(item){
			//判断是否登录，登录跳转到详情页，未登录弹出简介
			console.log(item)
			if(!globalData.userInfo.isLogin) {
				this.$refs.m_modal.more_info_show(item.ProductName, item.ProductNote)
				return;
			}
			go_product_introduct(item)
		}
	},
	filters: {
		
	}
})



